package com.upb.webserver.dao.mapper;

import com.upb.webserver.dao.entity.TbChainHost;
import com.upb.webserver.dao.entity.TbChainHostExample;
import java.util.List;
import java.util.Optional;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface TbChainHostMapper {

    @Delete({ "delete from tb_chain_host", "where chain_id = #{chainId,jdbcType=INTEGER}" })
    int deleteByChainId(@Param("chainId") Integer chainId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbChainHostSqlProvider.class, method = "countByExample")
    long countByExample(TbChainHostExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @DeleteProvider(type = TbChainHostSqlProvider.class, method = "deleteByExample")
    int deleteByExample(TbChainHostExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @Delete({ "delete from tb_chain_host", "where id = #{id,jdbcType=INTEGER}" })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @Insert({ "insert into tb_chain_host (chain_id, chain_type, ", "host_id, company_id, ", "node_count, gmt_create, ", "gmt_modified, description)", "values (#{chainId,jdbcType=INTEGER}, #{chainType,jdbcType=TINYINT}, ", "#{hostId,jdbcType=INTEGER}, #{companyId,jdbcType=INTEGER}, ", "#{nodeCount,jdbcType=INTEGER}, #{gmtCreate,jdbcType=TIMESTAMP}, ", "#{gmtModified,jdbcType=TIMESTAMP}, #{description,jdbcType=LONGVARCHAR})" })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insert(TbChainHost record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @InsertProvider(type = TbChainHostSqlProvider.class, method = "insertSelective")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insertSelective(TbChainHost record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbChainHostSqlProvider.class, method = "selectByExampleWithBLOBs")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "host_id", property = "hostId", jdbcType = JdbcType.INTEGER), @Result(column = "company_id", property = "companyId", jdbcType = JdbcType.INTEGER), @Result(column = "node_count", property = "nodeCount", jdbcType = JdbcType.INTEGER), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    List<TbChainHost> selectByExampleWithBLOBs(TbChainHostExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbChainHostSqlProvider.class, method = "selectByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "host_id", property = "hostId", jdbcType = JdbcType.INTEGER), @Result(column = "company_id", property = "companyId", jdbcType = JdbcType.INTEGER), @Result(column = "node_count", property = "nodeCount", jdbcType = JdbcType.INTEGER), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP) })
    List<TbChainHost> selectByExample(TbChainHostExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @Select({ "select", "id, chain_id, chain_type, host_id, company_id, node_count, gmt_create, gmt_modified, ", "description", "from tb_chain_host", "where id = #{id,jdbcType=INTEGER}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "host_id", property = "hostId", jdbcType = JdbcType.INTEGER), @Result(column = "company_id", property = "companyId", jdbcType = JdbcType.INTEGER), @Result(column = "node_count", property = "nodeCount", jdbcType = JdbcType.INTEGER), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    TbChainHost selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbChainHostSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") TbChainHost record, @Param("example") TbChainHostExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbChainHostSqlProvider.class, method = "updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") TbChainHost record, @Param("example") TbChainHostExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbChainHostSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") TbChainHost record, @Param("example") TbChainHostExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbChainHostSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TbChainHost record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @Update({ "update tb_chain_host", "set chain_id = #{chainId,jdbcType=INTEGER},", "chain_type = #{chainType,jdbcType=TINYINT},", "host_id = #{hostId,jdbcType=INTEGER},", "company_id = #{companyId,jdbcType=INTEGER},", "node_count = #{nodeCount,jdbcType=INTEGER},", "gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},", "gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},", "description = #{description,jdbcType=LONGVARCHAR}", "where id = #{id,jdbcType=INTEGER}" })
    int updateByPrimaryKeyWithBLOBs(TbChainHost record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @Update({ "update tb_chain_host", "set chain_id = #{chainId,jdbcType=INTEGER},", "chain_type = #{chainType,jdbcType=TINYINT},", "host_id = #{hostId,jdbcType=INTEGER},", "company_id = #{companyId,jdbcType=INTEGER},", "node_count = #{nodeCount,jdbcType=INTEGER},", "gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},", "gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}", "where id = #{id,jdbcType=INTEGER}" })
    int updateByPrimaryKey(TbChainHost record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert({ "<script>", "insert into tb_chain_host (chain_id, ", "chain_type, host_id, ", "company_id, node_count, ", "gmt_create, gmt_modified, ", "description)", "values<foreach collection=\"list\" item=\"detail\" index=\"index\" separator=\",\">(#{detail.chainId,jdbcType=INTEGER}, ", "#{detail.chainType,jdbcType=TINYINT}, #{detail.hostId,jdbcType=INTEGER}, ", "#{detail.companyId,jdbcType=INTEGER}, #{detail.nodeCount,jdbcType=INTEGER}, ", "#{detail.gmtCreate,jdbcType=TIMESTAMP}, #{detail.gmtModified,jdbcType=TIMESTAMP}, ", "#{detail.description,jdbcType=LONGVARCHAR})</foreach></script>" })
    int batchInsert(List<TbChainHost> list);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_host
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbChainHostSqlProvider.class, method = "getOneByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "host_id", property = "hostId", jdbcType = JdbcType.INTEGER), @Result(column = "company_id", property = "companyId", jdbcType = JdbcType.INTEGER), @Result(column = "node_count", property = "nodeCount", jdbcType = JdbcType.INTEGER), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    Optional<TbChainHost> getOneByExample(TbChainHostExample example);
}
